< previous page page_609 next page >

Page 609
0609-01.jpg
Figure 15.7.
The results of using the 
UPDATE_SET statement.
Note.gif
Notice that you did not include the column names in the INSERT INTO statements in this example. As long as you are supplying all the column values for a table, in the same order that they appear in the physical layout, you can omit the column names from the statement.

As you can see in Figure 15.7, all the records in the table are updated by the UPDATE_SET statement. The SET statement works for both numeric and character fields. It can contain any number of column updates, too. For example, if you have a table that has three fields that need to be updated, you can use the following SQL statement:
UPDATE MyTable SET
   CustType="RETAIL",
   CustDiscount=10,
   CustDate=#01/15/96#;
You can also add a WHERE clause to the UPDATE statement to limit the rows that are affected by the SET portion of the statement. What if you want to give anyone whose salary is over $30,000 a 10 percent raise and anyone whose salary is $30,000 or under a 15 percent raise? You could accomplish this with two UPDATE_SET statements that each contain a WHERE clause. Use the code in Listing 15.7 as a guide to modifying the SQLVB06.SQV script. Save your changes and run the script. Check your results against Figure 15.8.

 
< previous page page_609 next page >

If you like this book, buy it!